class CreateAdminUser < ActiveRecord::Migration
  def self.up
    if ENV['INTERACTIVE']
      print "Create an admin user account\n"
      print "\nEnter username (3-30 chars, no spaces or punctuation): "
      username = STDIN.gets.strip
      print "\nEnter password (5-30 chars, no spaces or punctuation): "
      password = STDIN.gets.strip
    else
      username = 'admin'
      password = 'admin'
    end
    say("Creating admin user => login: #{username}, password: #{password}")
    #admin user
    admin = User.new(
      :login => username, 
      :email => "admin@example.com", 
      :password => password,
      :password_confirmation => password
    )
    admin.save!
  end

  def self.down
  end
end
